﻿using System.Collections.Generic;
using Microsoft.Xna.Framework;

namespace Rocuna.Core
{
    /// <summary>
    /// Holder for screen 
    /// </summary>
    public abstract class Screen : DrawableGameComponent
    {
        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="Screen"/> class.
        /// </summary>
        protected Screen(Game game)
            : base(game)
        {
            Components = new List<IGameComponent>();
        }

        /// <summary>
        /// Gets or sets the components.
        /// </summary>
        /// <value>
        /// The components.
        /// </value>
        public List<IGameComponent> Components { get; set; }

        /// <summary>
        /// Activates this instance.
        /// </summary>
        public virtual void Activate()
        {
            Game.Components.Add(this);
            foreach (var gameComponent in Components)
            {
                Game.Components.Add(gameComponent);
            }
        }

        /// <summary>
        /// Deactivates this instance.
        /// </summary>
        public virtual void Deactivate()
        {
            Game.Components.Remove(this);
            foreach (var gameComponent in Components)
            {
                Game.Components.Remove(gameComponent);
            }
        }

        #endregion
    }
}